// Ofri Keidar 302933981 group 05

package view.useBeans;

/**
 * Bean class holding date's data
 */
public class DateData {

	String date;

	/**
	 * Sets the date
	 * @param date- date to set
	 */
	public void setDate(String date) { this.date = date; }
	
	/**
	 * Returns the date
	 * @return date attribute
	 */
	public String getDate() { return date; }	
	
	/**
	 * Checks if data had been already set.
	 * Data is set if member is not null nor empty string
	 * @return True if data is set, False if not
	 */
	public boolean isDataSet() {
		
		// validate date
		boolean dataSet = true;
		if (date == null) { dataSet = false; }
		else if (date.equals("")) { dataSet = false; }
		
		// check if parameter is set 
		return dataSet;
	}
	
	/**
	 * Checks if date represents a day, which means
	 * in the format of yyyy-mm-dd
	 * @return True if date is in format of yyyy-mm-dd, False if not
	 */
	public boolean isDay() {
		
		// check matching to format and return result
		return date.matches("\\d{4}-\\d{2}-\\d{2}");
	}
}